// 	Name: 08.c
//	Description: Chapter 5 project 8
//	Author: StableGenius
//	Date: 2020-05-07
//	Email: feng@dongfa.pro

#include <stdio.h>

int main(void){
	int hour, minute, minutes_after_0, 
		n1 = 480, // 8:00 a.m.
		n2 = 583,
		n3 = 679,
		n4 = 767,
		n5 = 840,
		n6 = 945,
		n7 = 1140,
		n8 = 1305;

    printf("Enter a 24-hour time: ");
    scanf("%d :%d", &hour, &minute);
    minutes_after_0 = hour * 60 + minute;
    
    if (minutes_after_0 <= n1 + (n2 - n1) / 2) {printf("Closest departure time is 8:00 a.m. arriving at 10:16 a.m.");}
    else if (minutes_after_0 <= n2 + (n3 - n2) / 2) {printf("Closest departure time is 9:43 p.m. arriving at 11:52 a.m.");}
    else if (minutes_after_0 <= n3 + (n4 - n3) / 2) {printf("Closest departure time is 11:19 p.m. arriving at 1:31 p.m.");}
    else if (minutes_after_0 <= n4 + (n5 - n4) / 2) {printf("Closest departure time is 12:47 p.m. arriving at 3:00 p.m.");}
    else if (minutes_after_0 <= n5 + (n6 - n5) / 2) {printf("Closest departure time is 2:00 p.m. arriving at 4:08 p.m.");}
    else if (minutes_after_0 <= n6 + (n7 - n6) / 2) {printf("Closest departure time is 3:45 p.m. arriving at 5:55 p.m.");}
    else if (minutes_after_0 <= n7 + (n8 - n7) / 2) {printf("Closest departure time is 7:00 p.m. arriving at 9:20 p.m.");}
    else printf("Closest departure time is 9:45 p.m. arriving at 11:58 p.m.");
    
	return 0;
}
